package cn.itcast.test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class asd {
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    public static void main(String[] args) {
        String asd = "1999-10-21 21:02:02";

        List<String> list = new ArrayList<>();
        list.add("1999-10-21 00:00:00");
        list.add("1200-10-14 00:00:00");
        list.add("2020-10-25 00:00:00");
        list.add("2021-10-10 00:00:00");
        list.add("2000-10-30 00:00:00");


        try {
            //遍历集合，得到每个时间提前三天的时间
            Calendar cal = Calendar.getInstance();
            for (String time : list) {
                //交货时间
                Date dateTime = sdf.parse(time);
                String format = sdf.format(dateTime);
                //System.out.println("time:"+time);
                //System.out.println("dateTime = "+dateTime);
                System.out.println("format = " + format);
                //得到三天前的时间
                cal.setTime(dateTime);
                cal.add(Calendar.HOUR,-72);
                String date = sdf.format(cal.getTime());
                //System.out.println("date = " + date);
            }
            Date newDate = new Date();
            String StrDate = sdf.format(newDate);
            System.out.println(StrDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
